<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="/godance/layui/src/css/layui.css" rel="stylesheet">
    <script src="/godance/layui/src/layui.js"></script>
    <script src="/godance/js/jquery-3.4.1.js"></script>
    <script src="/godance/js/My_js.js"></script>
    <script type="text/javascript">
        $(function () {
            var id =getQueryVariable("id")
            var title ="";
            var essay ="";
            var date ="";
            var author ="";
            $.ajax({
                url: "get_essay",
                dataType: "json",
                type: "post",
                data: {
                    "id": id,
                },
                dataTypes: "application/json",
                success: function (result) {
                    localStorage.setItem("title",result.title)
                    localStorage.setItem("essay", result.content)
                    localStorage.setItem("date", result.date)
                    localStorage.setItem("author", result.author)
                    title = localStorage.getItem("title")
                    essay = localStorage.getItem("essay")
                    date = localStorage.getItem("date")
                    author = localStorage.getItem("author")
                    console.log(date)
                    $("#title").html(title)
                    $("#date").html(date)
                    $("#essay").html(essay)
                    $("#author").html(author)
                }
            })
        })
        getQueryVariable = function (variable) {
            var query = window.location.search.substring(1);
            console.log("query"+query);
            var vars = query.split("&");
            console.log("vars"+vars)
            for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                console.log("pair"+pair);
                if(pair[0] == variable){return pair[1];}
            }
            return false;
        }
    </script>
</head>
<body>
<div id="all">
    <h1 style="text-align: center"><b id="title"></b></h1>
    <br/>
    <h2 style="text-align: center"><b id="author"></b>&nbsp;&nbsp;&nbsp;&nbsp;<b id="date"></b></h2>
    <br/>
    <h3 id="essay" style="text-align: center"></h3>
</div>
</body>
</html>